package com.panopset.gui.container;

import static com.panopset.Util.x;
import static com.panopset.UtilIO.mkdirs;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.LayoutManager;

import javax.swing.JFileChooser;

import com.panopset.gui.PopupBox;
import com.panopset.gui.TPanel;
import com.panopset.swing.AppPanopset;

/**
 * Directory path persistent container.
 *
 * @author Karl Dinwiddie
 *
 */
public class PanDirectory extends AbstractPanFile {

    /**
     * @param borderTitle
     *            Border title.
     * @param toolTipText
     *            Tool tip text.
     */
    public PanDirectory(final String borderTitle, final String toolTipText) {
        this(borderTitle, toolTipText, "");
    }

    /**
     *
     * @param borderTitle
     *            Border title.
     * @param toolTipText
     *            Tool tip text.
     * @param defaultValue
     *            Default value.
     */
    public PanDirectory(final String borderTitle, final String toolTipText,
            final String defaultValue) {
        super(borderTitle, toolTipText, defaultValue);
    }

    /**
     * @param s Not used.
     */
    public static void main(String...s) {
        new AppPanopset() {
            @Override
            public Component createMainPanel() {
                TPanel p = new TPanel(new BorderLayout());
                p.add(BorderLayout.CENTER, new PanDirectory("Test", "Testing", "C:").getPanel());
                return p;
            }
            @Override
            protected PopupBox getAboutBox() {
                return new PopupBox(new TPanel(), new Dimension(300, 300), app.f.getFrame());
            }

        }.show();
    }

    @Override
    protected String createPrompter() {
        return x("directory");
    }

    @Override
    protected int getFileSelectionMode() {
        return JFileChooser.DIRECTORIES_ONLY;
    }

    @Override
    protected void create() {
        mkdirs(getFile());
    }

    @Override
    protected LayoutManager createLayout() {
        return null;
    }

    @Override
    protected boolean isValid(final String valueToCheck) {
        return true;
    }
}
